package com.youdoneed.community.forum.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import com.youdoneed.base.application.AppException;
import com.youdoneed.community.forum.dao.ForummsglabelrelMapper;
import com.youdoneed.community.forum.entity.Forummsglabelrel;

/**
 * 帖子与标签的关联关系服务接口
 *
 * @author lid
 * @date 2017.6.7
 */
@Service
public class ForummsglabelrelService {
    private final Logger logger = LoggerFactory.getLogger(ForummsglabelrelService.class);

    @Autowired
    ForummsglabelrelMapper forummsglabelrelMapper;

    @Transactional
    public Forummsglabelrel selectById(String id) {
        logger.info("selectById!");
        if (!StringUtils.hasText(id)) {
            logger.info("id参数为空!");
            throw new AppException("id参数不能为空");
        }
        return forummsglabelrelMapper.selectByPrimaryKey(id);
    }

    @Transactional
    public int saveForummsglabelrel(Forummsglabelrel rel) {
        logger.info("saveForummsglabelrel!");
        if (null == rel) {
            logger.info("rel参数为空!");
            throw new AppException("rel参数不能为空");
        }
        return forummsglabelrelMapper.insert(rel);
    }
}
